/**
 * 订单操作
 * */


function getList(){
    $.ajax({
        type: apis.eqJf2g.method,
        url: apis.eqJf2g.url,
        data: {},
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                msgPop({msg: res.msg});
                return
            }
            var d = res.data;
            var h = '', i;
            for (i = 0; i < d.length; i ++) {
                h += '<tr class="text-c">';
                h += '<td>' + d[i].uname + '</td>';
                h += '<td>' + d[i].orderno + '</td>';
                h += '<td>' + d[i].num + '</td>';
                h += '<td style="width: 30%;">' + d[i].skuInfo + '</td>';
                if (d[i].wuliu == '') {
                    h += '<td>-</td>';
                } else {
                    h += '<td>快递公司：' + d[i].wuliu + '，<br>快递单号：' + d[i].wuliuhao + '</td>';
                }
                h += '<td>' + d[i].addtime + '</td>';
                h += '<td class="f-14">';
//					h += '<a href="javascript:;" onclick="order_show(\'详情\',\'order-show.html\', ' + d[i].id + ');">';
//					h += '详情';
//					h += '</a>';
                if (d[i].iscancel == 2) {
                    h += ' &nbsp; ';
                    h += '<a href="javascript:;" onclick="shenhe_yes(' + d[i].id + ');">';
                    h += '通过';
                    h += '</a>';
                }
                if (d[i].status == 2 && d[i].iscancel < 2) {
                    h += ' &nbsp; ';
                    h += '<a href="javascript:;" onclick="order_send(\'发货\',\'point/order-send.html\', ' + d[i].id + ');">';
                    h += '发货<i class="Hui-iconfont">&#xe6df;</i>';
                    h += '</a>';
                }
                h += '</td>';
                h += '</tr>';
            }
            $('tbody').html(h);
            $('#pageTotal').html(d.length);
            pages.total = res.total;
            pageHtml(pages);
        },
        error: function () {
            console.log('错误辣');
        }
    });
}


//审核通过弹窗
function shenhe_yes(v){
    var msg = '确认要 <b style="color: #0088CC; font-size: 20px;">通过审核</b> 吗？';
    layer.confirm(msg,function(index){
        shenhe({id: v});
    });
}


//审核弹窗
function shenhe(e){
    $.ajax({
        type: apis.eqJdOrderAuth.method,
        url: apis.eqJdOrderAuth.url,
        data: { id: e.id },
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                layerMsgErr(res.msg);
                return
            }
            layerMsgOk('操作成功');
            setTimeout(function(){
                top.location.reload();
            }, 1000);
        },
        error: function () {
            console.log('错误了！');
        }
    });
}


//发货通过弹窗
function order_send(title,url,id,w,h){
    url += '?id=' + id;
    layer_show(title,url,w,300);
}


//发货弹窗
function send(){
    var wuliu = $('#wuliu').val();
    var wuliuhao = $('#wuliuhao').val();
    if (!wuliuhao) {
        msgPop({msg: '物流号必须的'});
        return
    }
    var formData = {
        id: id,
        wuliu: wuliu,
        wuliuhao: wuliuhao,
    };
    console.log(formData);
    $.ajax({
        type: apis.eqJdOrderSend.method,
        url: apis.eqJdOrderSend.url,
        data: formData,
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                layerMsgErr(res.msg);
                return
            }
            layerMsgOk('操作成功');
            setTimeout(function(){
                top.location.reload();
            }, 1000);
        },
        error: function () {
            console.log('错误了！');
        }
    });
}